package co.com.services.medico;



import javax.naming.NamingException;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import co.com.smart.maestro.infraestructure.dto.MedicoDTO;
import co.com.smart.session.DelegateContextEJB;


@Path("/SmartMedicoService")
public class MedicoServices {
	@GET
	@Path("/getAllMedico")	
	@Produces(MediaType.APPLICATION_JSON)
	public Response getMedico() throws NamingException {
		return Response.ok(DelegateContextEJB.getMedicoBeanLocal().consultarAllMedico())
		.header("Access-Control-Allow-Origin", "*")
		.header("Access-Control-Allow-Methods", "POST, GET, PUT, UPDATE, OPTIONS")
		.header("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With").build();
	}

	@POST
	@Path("/getMedicoId")	
	@Produces(MediaType.APPLICATION_JSON)
	public Response getMedicoId(MedicoDTO json) throws NamingException {
		return Response.ok(DelegateContextEJB.getMedicoBeanLocal().consultarMedicoId(json))
		.header("Access-Control-Allow-Origin", "*")
		.header("Access-Control-Allow-Methods", "POST, GET, PUT, UPDATE, OPTIONS")
		.header("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With").build();
	}

	@PUT
	@Path("/setMedico")
	@Consumes(MediaType.APPLICATION_JSON)
	@Produces(MediaType.APPLICATION_JSON)
	public Response setMedico( MedicoDTO json){ 
		return Response.ok(DelegateContextEJB.getMedicoBeanLocal().insertarMedico(json))
				.header("Access-Control-Allow-Origin", "*")
				.header("Access-Control-Allow-Methods", "POST, GET, PUT, UPDATE, OPTIONS")
				.header("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With")
				.build();
	}

	@PUT
	@Path("/editMedico")
	@Consumes(MediaType.APPLICATION_JSON)
	@Produces(MediaType.APPLICATION_JSON)
	public Response setEditMedico(MedicoDTO json){ 
		return Response.ok(DelegateContextEJB.getMedicoBeanLocal().editMedico(json))
		.header("Access-Control-Allow-Origin", "*")
		.header("Access-Control-Allow-Methods", "POST, GET, PUT, UPDATE, OPTIONS")
		.header("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With").build();
	}

	@PUT
	@Path("/removeMedico")
	@Consumes(MediaType.APPLICATION_JSON)
	@Produces(MediaType.APPLICATION_JSON)
	public Response setRemoveMedico(MedicoDTO json){ 
		return Response.ok(DelegateContextEJB.getMedicoBeanLocal().removeMedico(json, true))
				.header("Access-Control-Allow-Origin", "*")
				.header("Access-Control-Allow-Methods", "POST, GET, PUT, UPDATE, OPTIONS")
				.header("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With").build();
	}



	
}
